package com.netsdk.demo.customize;

import com.netsdk.demo.util.CaseMenu;
import com.netsdk.lib.NetSDKLib;
import com.netsdk.lib.PlaySDKLib;
import com.netsdk.lib.ToolKits;
import com.netsdk.lib.enumeration.*;
import com.netsdk.lib.structure.*;
import com.netsdk.lib.utils.Initialization;
import com.sun.jna.Memory;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Objects;

public class FireWarningDemo extends Initialization {


    /**变量区**/
    static NetSDKLib netsdkApi 	= NetSDKLib.NETSDK_INSTANCE;
    static NetSDKLib configApi 	= NetSDKLib.CONFIG_INSTANCE;
    static PlaySDKLib playsdkApi   = PlaySDKLib.PLAYSDK_INSTANCE;
    NetSDKLib.LLong    attachHandle=new NetSDKLib.LLong(0);
    int channel=0;

    /**方法区**/

    /**
     * 方法模板
     */
    public void MethodTemplate() {
        // MethodContent
    }

    /**
     * 获取火警拓展配置
     */
    public boolean GetSetDevConfig_FIRE_WARNING_EXT() {

        String command = EM_NEW_CONFIG.CFG_CMD_FIRE_WARNING_EXT.getValue();
        CFG_FIREWARNING_EXT_INFO msg = new CFG_FIREWARNING_EXT_INFO();

        if(ToolKits.GetDevConfig(loginHandle, channel, command, msg)) { // 获取
            System.out.println("GetDevConfig-CFG_CMD_FIRE_WARNING_EXT succeed!");
            System.out.println("bVisualDetailEnable = " + msg.bVisualDetailEnable);
            System.out.println("bVisualOverviewEnable = " + msg.bVisualOverviewEnable);
            System.out.println("nThermoSnapTimes = " + msg.nThermoSnapTimes);
            if(ToolKits.SetDevConfig(loginHandle, channel, command, msg)) {
                System.out.println("SetDevConfig-CFG_CMD_FIRE_WARNING_EXT succeed!");
                return true;
            } else {
                System.err.println("SetDevConfig-CFG_CMD_FIRE_WARNING_EXT failed!" + ToolKits.getErrorCode());
            }
        } else {
            System.err.println("GetDevConfig-CFG_CMD_FIRE_WARNING_EXT failed!" + ToolKits.getErrorCode());
        }
        return false;
    }

    public void GetSetConfig_FIRE_WARNING() {
        int emCfgOpType= NET_EM_CFG_OPERATE_TYPE.NET_EM_CFG_FIRE_WARNING;
        NetSDKLib.NET_FIRE_WARNING_INFO msg=new NetSDKLib.NET_FIRE_WARNING_INFO();

        int dwOutBufferSize=msg.size();
        Pointer szOutBuffer =new Memory(dwOutBufferSize);
        ToolKits.SetStructDataToPointer(msg, szOutBuffer, 0);
        boolean ret=netSdk.CLIENT_GetConfig(loginHandle, emCfgOpType, 1, szOutBuffer, dwOutBufferSize, 3000, null);
        if(!ret) {
            System.err.printf("GetConfig-NET_EM_CFG_FIRE_WARNING failed, ErrCode=%x\n", netSdk.CLIENT_GetLastError());
            return;
        } else {
            System.out.println("GetConfig-NET_EM_CFG_FIRE_WARNING succeed!");
        }
        ToolKits.GetPointerData(szOutBuffer, msg);
        System.out.println("火灾预警配置个数"+msg.nFireWarnRuleNum+
                "\n使能"+msg.stuFireWarnRule[0].bEnable);

        //下发时如需修改，则在此处修改结构体的值，如下
        //msg.stuFireWarnRule[0].bEnable = 0;

        IntByReference restart = new IntByReference(0);
        int dwInBufferSize=msg.size();
        Pointer szInBuffer =new Memory(dwInBufferSize);
        ToolKits.SetStructDataToPointer(msg, szInBuffer, 0);
        boolean result=netSdk.CLIENT_SetConfig(loginHandle, emCfgOpType, 1, szInBuffer, dwInBufferSize, 3000, restart, null);
        if(!result) {
            System.err.printf("SetConfig-NET_EM_CFG_FIRE_WARNING failed, ErrCode=%x\n", netSdk.CLIENT_GetLastError());
        }else {
            System.out.println("SetConfig-NET_EM_CFG_FIRE_WARNING succeed");
        }
    }

    /**
     * 获取状态信息接口
     */
    public void GetCalibrateInfo() {
        //枚举类型
        int emType = EM_CALIBRATEINFO_OPERATE_TYPE.EM_CALIBRATEINFO_OPERATE_GET.getValue(); // 智能终端箱的异常状态,对应结构体NET_CASEABNORMAL_STATE_INFO
        // 入参
        NET_IN_GET_CALIBRATEINFO_INFO pIn = new NET_IN_GET_CALIBRATEINFO_INFO();
        pIn.nID = 1;
        pIn.nChannel = channel;
        pIn.write();
        // 出参
        NET_OUT_GET_CALIBRATEINFO_INFO pOut = new NET_OUT_GET_CALIBRATEINFO_INFO();
        pOut.write();

        boolean flg = netsdkApi.CLIENT_OperateCalibrateInfo(loginHandle,emType, pIn.getPointer(), pOut.getPointer(), 3000);
        if (!flg) {
            System.err.println("CLIENT_OperateCalibrateInfo-EM_CALIBRATEINFO_OPERATE_GET failed:" + ToolKits.getErrorCode());
        } else {
            System.out.println("CLIENT_OperateCalibrateInfo-EM_CALIBRATEINFO_OPERATE_GET succeed");
            pIn.read();
            pOut.read();
            System.out.println("stuPointInfo.nID = " + pOut.stuPointInfo.nID);
            System.out.println("stuPointInfo.bEnable = " + pOut.stuPointInfo.bEnable);
            System.out.println("stuPointInfo.nLatitude = " + pOut.stuPointInfo.nLatitude);
            System.out.println("stuPointInfo.nLongitude = " + pOut.stuPointInfo.nLongitude);
            System.out.println("stuPointInfo.fAltitude = " + pOut.stuPointInfo.fAltitude);
            System.out.println("stuPointInfo.nPointNum = " + pOut.stuPointInfo.nPointNum);
            System.out.println("stuPointInfo.szName = " + new String(pOut.stuPointInfo.szName).trim());
            for(int i = 0; i < pOut.stuPointInfo.nPointNum; i ++){
                System.out.println("pOut.stuPointInfo.stuCalcInfo[" + i + "].fPosition = " + pOut.stuPointInfo.stuCalcInfo[i].fPosition);
                System.out.println("pOut.stuPointInfo.stuCalcInfo[" + i + "].nLocation = " + pOut.stuPointInfo.stuCalcInfo[i].nLocation);
            }
        }
    }

    /**
     * 下发状态信息接口
     */
    public void SetCalibrateInfo() {
        //枚举类型
        int emType = EM_CALIBRATEINFO_OPERATE_TYPE.EM_CALIBRATEINFO_OPERATE_SET.getValue(); // 智能终端箱的异常状态,对应结构体NET_CASEABNORMAL_STATE_INFO
        // 入参
        NET_IN_SET_CALIBRATEINFO_INFO pIn = new NET_IN_SET_CALIBRATEINFO_INFO();
        pIn.stuPointInfo.nID = 1;
        pIn.stuPointInfo.bEnable = 1;
        pIn.stuPointInfo.nLatitude = 5;
        pIn.stuPointInfo.nLongitude = 3;
        pIn.stuPointInfo.fAltitude = 4.7;
        pIn.stuPointInfo.nPointNum = 2;
        System.arraycopy("BRS_CANON".getBytes(), 0, pIn.stuPointInfo.szName, 0, "BRS_CANON".getBytes().length);
        for(int i = 0; i < pIn.stuPointInfo.nPointNum*2; i ++){
           pIn.stuPointInfo.stuCalcInfo[i].nLocation = new int[] {i,i+1};
            pIn.stuPointInfo.stuCalcInfo[i].fPosition = new float[] {i,i+1,i+2};
            pIn.stuPointInfo.stuCalcInfo[i].write();
        }
        pIn.write();
        // 出参
        NET_OUT_SET_CALIBRATEINFO_INFO pOut = new NET_OUT_SET_CALIBRATEINFO_INFO();
        pOut.write();

        boolean flg = netsdkApi.CLIENT_OperateCalibrateInfo(loginHandle,emType, pIn.getPointer(), pOut.getPointer(), 3000);
        if (!flg) {
            System.err.println("CLIENT_OperateCalibrateInfo-EM_CALIBRATEINFO_OPERATE_SET failed:" + ToolKits.getErrorCode());
        } else {
            System.out.println("CLIENT_OperateCalibrateInfo-EM_CALIBRATEINFO_OPERATE_SET succeed");
        }
    }

    /**
     * 删除状态信息接口
     */
    public void DeleteCalibrateInfo() {
        //枚举类型
        int emType = EM_CALIBRATEINFO_OPERATE_TYPE.EM_CALIBRATEINFO_OPERATE_DELETE.getValue(); // 智能终端箱的异常状态,对应结构体NET_CASEABNORMAL_STATE_INFO
        // 入参
        NET_IN_DELETE_CALIBRATEINFO_INFO pIn = new NET_IN_DELETE_CALIBRATEINFO_INFO();
        pIn.nID = 1;
        pIn.write();
        // 出参
        NET_OUT_DELETE_CALIBRATEINFO_INFO pOut = new NET_OUT_DELETE_CALIBRATEINFO_INFO();
        pOut.write();

        boolean flg = netsdkApi.CLIENT_OperateCalibrateInfo(loginHandle,emType, pIn.getPointer(), pOut.getPointer(), 3000);
        if (!flg) {
            System.err.println("CLIENT_OperateCalibrateInfo-EM_CALIBRATEINFO_OPERATE_DELETE failed:" + ToolKits.getErrorCode());
        } else {
            System.out.println("CLIENT_OperateCalibrateInfo-EM_CALIBRATEINFO_OPERATE_DELETE succeed");
        }
    }

    /**
     * 获取状态信息接口
     */
    public void GetAllCalibrateInfo() {
        //枚举类型
        int emType = EM_CALIBRATEINFO_OPERATE_TYPE.EM_CALIBRATEINFO_OPERATE_GETALL.getValue(); // 智能终端箱的异常状态,对应结构体NET_CASEABNORMAL_STATE_INFO
        // 入参
        NET_IN_GETALL_CALIBRATEINFO_INFO pIn = new NET_IN_GETALL_CALIBRATEINFO_INFO();
        pIn.nChannel = channel;
        pIn.write();
        // 出参
        NET_OUT_GETALL_CALIBRATEINFO_INFO pOut = new NET_OUT_GETALL_CALIBRATEINFO_INFO();
        pOut.write();

        boolean flg = netsdkApi.CLIENT_OperateCalibrateInfo(loginHandle,emType, pIn.getPointer(), pOut.getPointer(), 3000);
        if (!flg) {
            System.err.println("CLIENT_OperateCalibrateInfo-EM_CALIBRATEINFO_OPERATE_GETALL failed:" + ToolKits.getErrorCode());
        } else {
            System.out.println("CLIENT_OperateCalibrateInfo-EM_CALIBRATEINFO_OPERATE_GETALL succeed");
            pIn.read();
            pOut.read();

            System.out.println("stuGPSInfo.unLatitude = " + pOut.stuGPSInfo.unLatitude);
            System.out.println("stuGPSInfo.unLongitude = " + pOut.stuGPSInfo.unLongitude);
            System.out.println("stuGPSInfo.dbAltitude = " + pOut.stuGPSInfo.dbAltitude);
            System.out.println("stuGPSInfo.bConfigEnable = " + pOut.stuGPSInfo.bConfigEnable);
            System.out.println("stuGPSInfo.fHeight = " + pOut.stuGPSInfo.fHeight);

            System.out.println("stuLocationCalibrateInfo.nThermoMaxHFOV = " + pOut.stuLocationCalibrateInfo.nThermoMaxHFOV);
            System.out.println("stuLocationCalibrateInfo.nThermoMaxVFOV = " + pOut.stuLocationCalibrateInfo.nThermoMaxVFOV);
            System.out.println("stuLocationCalibrateInfo.nVisualMaxHFOV = " + pOut.stuLocationCalibrateInfo.nVisualMaxHFOV);
            System.out.println("stuLocationCalibrateInfo.nVisualMaxVFOV = " + pOut.stuLocationCalibrateInfo.nVisualMaxVFOV);
            System.out.println("stuLocationCalibrateInfo.nPointNum = " + pOut.stuLocationCalibrateInfo.nPointNum);
            for(int i = 0; i < pOut.stuLocationCalibrateInfo.nPointNum; i ++){



                System.out.println("stuLocationCalibrateInfo.stuPointInfo["+i+"].nID = " + pOut.stuLocationCalibrateInfo.stuPointInfo[i].nID);
                System.out.println("stuLocationCalibrateInfo.stuPointInfo["+i+"].bEnable = " + pOut.stuLocationCalibrateInfo.stuPointInfo[i].bEnable);
                System.out.println("stuLocationCalibrateInfo.stuPointInfo["+i+"].nLatitude = " + pOut.stuLocationCalibrateInfo.stuPointInfo[i].nLatitude);
                System.out.println("stuLocationCalibrateInfo.stuPointInfo["+i+"].nLongitude = " + pOut.stuLocationCalibrateInfo.stuPointInfo[i].nLongitude);
                System.out.println("stuLocationCalibrateInfo.stuPointInfo["+i+"].fAltitude = " + pOut.stuLocationCalibrateInfo.stuPointInfo[i].fAltitude);
                System.out.println("stuLocationCalibrateInfo.stuPointInfo["+i+"].szName = " + new String(pOut.stuLocationCalibrateInfo.stuPointInfo[i].szName).trim());
                System.out.println("stuLocationCalibrateInfo.stuPointInfo["+i+"].stuCalibrateInfo.nInfoNum = " + pOut.stuLocationCalibrateInfo.stuPointInfo[i].stuCalibrateInfo.nInfoNum);

                for(int j = 0; j < pOut.stuLocationCalibrateInfo.stuPointInfo[i].stuCalibrateInfo.nInfoNum; j ++){
                    System.out.println("pOut.stuLocationCalibrateInfo.stuPointInfo["+i+"].stuCalibrateInfo.stuCalibrateUnitInfo["+j+"].nHeight = "
                            + pOut.stuLocationCalibrateInfo.stuPointInfo[i].stuCalibrateInfo.stuCalibrateUnitInfo[j].nHeight);
                    System.out.println("pOut.stuLocationCalibrateInfo.stuPointInfo["+i+"].stuCalibrateInfo.stuCalibrateUnitInfo["+j+"].nWidth = "
                            + pOut.stuLocationCalibrateInfo.stuPointInfo[i].stuCalibrateInfo.stuCalibrateUnitInfo[j].nWidth);
                    System.out.println("pOut.stuLocationCalibrateInfo.stuPointInfo["+i+"].stuCalibrateInfo.stuCalibrateUnitInfo["+j+"].nHFOV = "
                            + pOut.stuLocationCalibrateInfo.stuPointInfo[i].stuCalibrateInfo.stuCalibrateUnitInfo[j].nHFOV);
                    System.out.println("pOut.stuLocationCalibrateInfo.stuPointInfo["+i+"].stuCalibrateInfo.stuCalibrateUnitInfo["+j+"].nVFOV = "
                            + pOut.stuLocationCalibrateInfo.stuPointInfo[i].stuCalibrateInfo.stuCalibrateUnitInfo[j].nVFOV);
                    System.out.println("pOut.stuLocationCalibrateInfo.stuPointInfo["+i+"].stuCalibrateInfo.stuCalibrateUnitInfo["+j+"].nLocation = "
                            + pOut.stuLocationCalibrateInfo.stuPointInfo[i].stuCalibrateInfo.stuCalibrateUnitInfo[j].nLocation.toString());
                    System.out.println("pOut.stuLocationCalibrateInfo.stuPointInfo["+i+"].stuCalibrateInfo.stuCalibrateUnitInfo["+j+"].nPosition = "
                            + pOut.stuLocationCalibrateInfo.stuPointInfo[i].stuCalibrateInfo.stuCalibrateUnitInfo[j].nPosition.toString());
                }
            }
        }
    }
    /**
     * 订阅智能任务
     */

    public NetSDKLib.LLong AttachEventRealLoadPic() {
        // 先退订，设备不会对重复订阅作校验，重复订阅后会有重复的事件返回
        if(attachHandle.longValue()!=0){
            this.DetachEventRealLoadPic();
        }
        int nchannel = 1;
        // 需要图片
        int bNeedPicture = 1;
        attachHandle = netSdk.CLIENT_RealLoadPictureEx(loginHandle, nchannel, EM_EVENT_TYPE.EVENT_IVS_ALL.getType(), bNeedPicture,
                FireWarningDemo.AnalyzerDataCB.getInstance(), null, null);
        if (attachHandle.longValue() != 0) {
            System.out.printf("Chn[%d] CLIENT_RealLoadPictureEx Success\n", nchannel);
        } else {
            System.out.printf("Chn[%d] CLIENT_RealLoadPictureEx Failed!LastError = %s\n", nchannel,
                    ToolKits.getErrorCode());
        }

        return attachHandle;
    }
    /**
     * 报警事件（智能）回调
     */
    private static class AnalyzerDataCB implements NetSDKLib.fAnalyzerDataCallBack {
        private final File picturePath;
        private static FireWarningDemo.AnalyzerDataCB instance;

        private AnalyzerDataCB() {
            picturePath = new File("./AnalyzerPicture/");
            if (!picturePath.exists()) {
                picturePath.mkdirs();
            }
        }

        public static FireWarningDemo.AnalyzerDataCB getInstance() {
            if (instance == null) {
                synchronized (FireWarningDemo.AnalyzerDataCB.class) {
                    if (instance == null) {
                        instance = new FireWarningDemo.AnalyzerDataCB();
                    }
                }
            }
            return instance;
        }

        @Override
        public int invoke(NetSDKLib.LLong lAnalyzerHandle, int dwAlarmType, Pointer pAlarmInfo, Pointer pBuffer, int dwBufSize,
                          Pointer dwUser, int nSequence, Pointer reserved) throws UnsupportedEncodingException {
            if (lAnalyzerHandle == null || lAnalyzerHandle.longValue() == 0) {
                return -1;
            }

            System.out.println("===================================EVENT RECEIVED=======================================");
//            System.out.println(Objects.requireNonNull(EM_EVENT_IVS_TYPE.getEventType(dwAlarmType)).getDescription());
            switch (Objects.requireNonNull(EM_EVENT_IVS_TYPE.getEventType(dwAlarmType))) {
                case EVENT_IVS_HOTSPOT_WARNING : {
                    System.out.println("热点异常报警事件, code = " + dwAlarmType);

                    DEV_EVENT_HOTSPOT_WARNING_INFO msg = new DEV_EVENT_HOTSPOT_WARNING_INFO();

                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    //事件名称
                    byte[] szName = msg.szName;
                    System.out.println("szName:" + new String(szName));
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    System.out.println("pts:" + new Date((long) pts));
                    //UTC时间
                    NET_TIME_EX UTC = msg.UTC;
                    System.out.println("UTC:" + UTC.toStringTime());
                    //事件id
                    int nEventID = msg.nEventID;
                    System.out.println("nEventID:" + nEventID);
                    //事件对应文件信息
                    NetSDKLib.NET_EVENT_FILE_INFO stuFileInfo = msg.stuFileInfo;
                    System.out.println("stuFileInfo:" + stuFileInfo.toString());

                    System.out.println("nTemperatureUnit:" + msg.nTemperatureUnit);
                    System.out.println("fHotSpotValue:" + msg.fHotSpotValue);
                    //图片保存
                    if (dwBufSize > 0) {
                        String picture = picturePath + "/" + System.currentTimeMillis() + "related_EVENT_IVS_HOTSPOT_WARNING.jpg";
                        ToolKits.savePicture(pBuffer, 0, dwBufSize, picture);
                    }
                }
                default:
                    System.out.println("其他事件--------------------"+ dwAlarmType);
                    break;
            }
            return 0;
        }
    }


    /**
     * 停止侦听智能事件
     */
    public void DetachEventRealLoadPic() {
        if (this.attachHandle.longValue() != 0) {
            netSdk.CLIENT_StopLoadPic(this.attachHandle);
        }
    }

    /**
     * 查询门（开、关）状态
     */
    public void queryPTZLocation() {
        int cmd = NetSDKLib.NET_DEVSTATE_PTZ_LOCATION;
        NetSDKLib.NET_PTZ_LOCATION_INFO ptzInfo = new NetSDKLib.NET_PTZ_LOCATION_INFO();
        IntByReference retLenByReference = new IntByReference(0);

        ptzInfo.write();
        boolean bRet = netsdkApi.CLIENT_QueryDevState(loginHandle,
                cmd,
                ptzInfo.getPointer(),
                ptzInfo.size(),
                retLenByReference,
                3000);
        ptzInfo.read();
        if (!bRet) {
            System.err.println("queryPTZLocation failed. Error Code 0x"
                    + Integer.toHexString(netsdkApi.CLIENT_GetLastError()));
            return;
        } else {
            System.out.println("queryPTZLocation succeed");
            System.out.println("nPTZPan = " + ptzInfo.nPTZPan);
            System.out.println("nPTZTilt = " + ptzInfo.nPTZTilt);
            System.out.println("nPTZZoom = " + ptzInfo.nPTZZoom);
            System.out.println("fFocusPosition = " + ptzInfo.fFocusPosition);
            System.out.println("nZoomValue = " + ptzInfo.nZoomValue);
        }

    }

    private static final NetSDKLib.fMessCallBackEx1 messageCallBack = NoPicListenMessageCB.getSingleInstance();
    /**
     * 订阅一般报警事件
     */
    public void AttachEventStartListen() {
        netsdkApi.CLIENT_SetDVRMessCallBack(messageCallBack, null);
        // 一般报警不需要指定通道，自动全通道订阅
        boolean bRet = netSdk.CLIENT_StartListenEx(loginHandle);
        if (bRet) {
            System.out.println("CLIENT_StartListenEx Succeed.");
        } else {
            System.err.printf("CLIENT_StartListenEx fail, error:%s\n", ToolKits.getErrorCode());
        }
    }

    /**
     * 退订一般报警事件
     */
    public void DetachEventStopListen() {
        boolean bRet = netSdk.CLIENT_StopListen(loginHandle);
        if (bRet) {
            System.out.println("CLIENT_StopListen succeed");
        } else {
            System.err.printf("CLIENT_StopListen fail, error:%s\n", ToolKits.getErrorCode());
        }
    }

    public void RunTest()
    {
        System.out.println("Run Test");
        CaseMenu menu = new CaseMenu();;
        menu.addItem((new CaseMenu.Item(this , "GetSetDevConfig_FIRE_WARNING_EXT" , "GetSetDevConfig_FIRE_WARNING_EXT")));
        menu.addItem((new CaseMenu.Item(this , "GetSetConfig_FIRE_WARNING" , "GetSetConfig_FIRE_WARNING")));
        menu.addItem((new CaseMenu.Item(this , "GetCalibrateInfo" , "GetCalibrateInfo")));
        menu.addItem((new CaseMenu.Item(this , "SetCalibrateInfo" , "SetCalibrateInfo")));
        menu.addItem((new CaseMenu.Item(this , "DeleteCalibrateInfo" , "DeleteCalibrateInfo")));
        menu.addItem((new CaseMenu.Item(this , "GetAllCalibrateInfo" , "GetAllCalibrateInfo")));
        menu.addItem((new CaseMenu.Item(this , "AttachEventRealLoadPic" , "AttachEventRealLoadPic")));
        menu.addItem((new CaseMenu.Item(this , "DetachEventRealLoadPic" , "DetachEventRealLoadPic")));
        menu.addItem((new CaseMenu.Item(this , "queryPTZLocation" , "queryPTZLocation")));
        menu.addItem((new CaseMenu.Item(this , "AttachEventStartListen" , "AttachEventStartListen")));
        menu.addItem((new CaseMenu.Item(this , "DetachEventStopListen" , "DetachEventStopListen")));
        menu.run();
    }

    public static void main(String[] args) {
        FireWarningDemo demo = new FireWarningDemo();
        /**登录信息运行时输入**/
//        Scanner sc = new Scanner(System.in);
//        System.out.print("ip:");
//        String ip = sc.nextLine();
//        System.out.print("port:");
//        String tmp = sc.nextLine();
//        int port = Integer.parseInt(tmp);
//        System.out.print("username:");
//        String username = sc.nextLine();
//        System.out.print("password:");
//        String pwd = sc.nextLine();
//        InitTest(ip,port,username,pwd);
        /**登录信息固定**/
        InitTest("10.35.246.136",37777,"admin","admin123");

        demo.RunTest();
        LoginOut();

    }
}
